package com.cgbl.cg.vm.course

import android.app.Application
import androidx.databinding.ObservableField
import api.CourseServiceFactory
import com.robot.base.base.vm.GLBaseViewModel
import com.robot.base.common.api.AbstractViewModelSubscriber
import com.robot.base.model.CourseAllTypeBean
import com.robot.base.model.CourseBean
import com.robot.base.model.PageListBean
import com.tencent.connect.api.QQAuthManage.Resp
import me.goldze.mvvmhabit.binding.command.BindingAction
import me.goldze.mvvmhabit.binding.command.BindingCommand
import me.goldze.mvvmhabit.bus.event.SingleLiveEvent
import me.goldze.mvvmhabit.http.BaseResponse

class CourseMenuActViewModel(application: Application) : GLBaseViewModel(application) {
    val typeName = ObservableField("3D建模")
    var typeId = ""
    val list = arrayListOf<CourseAllTypeBean>()
    val uc = UiChangeEvent()

    class UiChangeEvent {
        val selectType: SingleLiveEvent<ArrayList<CourseAllTypeBean>> = SingleLiveEvent()
    }

    val showDialogCommand = BindingCommand<Any>(BindingAction {
        uc.selectType.call()
    })

    fun initData(typeList: MutableList<CourseAllTypeBean>, firstMenuPosition: Int) {
        list.clear()
        list.addAll(typeList)
        if (typeList.isNotEmpty()) {
            typeName.set(typeList[firstMenuPosition].name)
            typeId = typeList[firstMenuPosition].id ?: ""
        }
    }

}